#include "task_manager.h"
#include "com_lora.h"
#include "SEGGER_RTT.h"

void task_rx_lora(void *pvParameters)
{
    bsp_uart_driver_t* drv = lora_drv();

    xTaskCreate(task_tx_lora, \
                "tx_lora", \
                TASK_LORA_TX_STK_SIZE, \
                NULL, \
                TASK_LORA_TX_PRIO, \
                NULL);
    while(1)
    {
        /* 阻塞读取lora数据 */
        uint8_t byte = 0;
        drv->ops.read(drv, &byte, 1);

        /* 按字节解析数据 */
        lora_receive_analysis(byte);
    }
}   

static struct _protocol pack;
void task_tx_lora(void *pvParameters)
{
    bsp_uart_driver_t* drv = lora_drv();
    
    while(1)
    {
        xQueueReceive(drv->port.tx_queue, &pack, portMAX_DELAY);
        drv->ops.write(drv, (uint8_t*)&pack.buff, pack.size);
    }
}   
